package reflect;

import java.util.Scanner;

public class ReflectDemo2 {
    public static void main(String[] args) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
        Person p = new Person();
        System.out.println(p);

//        Class cls = Person.class;

//        Class cls = Class.forName("reflect.Person");
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入一个类的完全限定名");
        String className = scanner.nextLine();

        Class cls = Class.forName(className);
        Object obj = cls.newInstance();
        System.out.println(obj);
    }
}
